package com.cpd.blog.controller;

import com.cpd.blog.dto.Result;
import com.cpd.blog.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 分类接口
 *
 * @author Copydown
 * @date 2021/8/18 14:59
 */
@Api(tags = "文章分类模块")
@RestController
@RequestMapping("categorys")
@RequiredArgsConstructor
public class CategoryController {

    private final CategoryService categoryService;

    @ApiOperation("分类 接口")
    @GetMapping
    public Result categories() {
        return categoryService.finAll();
    }

    @ApiOperation("所有分类接详情 接口")
    @GetMapping("detail")
    public Result categoriesDetail() {
        return categoryService.finAllDetail();
    }

    @ApiOperation("搜索单个分类接详 情口")
    @GetMapping("detail/{id}")
    public Result categoryDetailById(@PathVariable("id") Long id) {
        return categoryService.categoryDetailById(id);
    }
}
